extends Node2D

@export var value = 1	## 金币的价值

@onready var area = $Area2D
@onready var api = Api.new()

func _ready():
	area.connect("body_entered", bodyEntered)


func bodyEntered(body):
	# 发起网络请求, 统计玩家拾取的金币
	var root = get_tree().root.get_child(0)
	api.updateOrCreate(
		root,
		root.mac,
		{"moneyCount": value},
		func (_data):
			pass
	)
	# 玩家拾取金币
	body.money.addX(value)
	self.queue_free()
		
